package com.rs.game.player.dialogues.impl;

import com.rs.game.player.Player;
import com.rs.game.player.content.dungeoneering.DungeonConstants;
import com.rs.game.player.content.dungeoneering.DungeonPartyManager;
import com.rs.game.player.dialogues.Dialogue;


public class DungSelect extends Dialogue {


	@Override
	public void start() {
		sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
	}

	public void run(int interfaceId, int componentId) {
		if (stage == -1) {
			if (componentId == OPTION_1) {
				if (player.getSkills().getLevel(24) < 1) {
					player.getPackets().sendGameMessage("You need a dungeoneering level of at least 1 in order to start a Frozen Floor.");
					end();
					return;
				} else {
				sendOptionsDialogue("Select your floor size", "Small", "Medium", "Large", "Back");
				stage = 0;
				}
			} else if (componentId == OPTION_2) {
				if (player.getSkills().getLevel(24) < 23) {
					player.getPackets().sendGameMessage("You need a dungeoneering level of at least 23 in order to start an Abandoned Floor.");
					end();
					return;
				} else {
				sendOptionsDialogue("Select your floor size", "Small", "Medium", "Large", "Back");
				stage = 1;
				}
			} else if (componentId == OPTION_3) {
				if (player.getSkills().getLevel(24) < 35) {
					player.getPackets().sendGameMessage("You need a dungeoneering level of at least 35 in order to start a Furnished Floor.");
					end();
					return;
				} else {
				sendOptionsDialogue("Select your floor size", "Small", "Medium", "Large", "Back");
				stage = 2;
				}	
			} else if (componentId == OPTION_4) {
				if (player.getSkills().getLevel(24) < 59) {
					player.getPackets().sendGameMessage("You need a dungeoneering level of at least 59 in order to start an Abandoned2 Floor.");
					end();
					return;
				} else {
				sendOptionsDialogue("Select your floor size", "Small", "Medium", "Large", "Back");
				stage = 3;
				}
			} else if (componentId == OPTION_5) {
				sendOptionsDialogue("Select your type of floor", "Occult Floor", "Warped Floor", "Back");
				stage = 4;
			}
		} else if (stage == 0) {
			if (componentId == OPTION_1) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.SMALL_DUNGEON, 11, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_2) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.MEDIUM_DUNGEON, 11, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_3) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.LARGE_DUNGEON, 11, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_4) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		} else if (stage == 1) {
			if (componentId == OPTION_1) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.SMALL_DUNGEON, 17, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_2) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.MEDIUM_DUNGEON, 17, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_3) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.LARGE_DUNGEON, 17, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_4) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		} else if (stage == 2) {
			if (componentId == OPTION_1) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.SMALL_DUNGEON, 29, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_2) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.MEDIUM_DUNGEON, 29, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_3) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.LARGE_DUNGEON, 29, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_4) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		} else if (stage == 3) {
			if (componentId == OPTION_1) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.SMALL_DUNGEON, 35, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_2) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.MEDIUM_DUNGEON, 35, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_3) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.LARGE_DUNGEON, 35, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_4) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		} else if (stage == 4) {
			if (componentId == OPTION_1) {
				if (player.getSkills().getLevel(24) < 71) {
					player.getPackets().sendGameMessage("You need a dungeoneering level of at least 71 in order to start an Occult Floor.");
					end();
					return;
				} else {
					sendOptionsDialogue("Select your floor size", "Small", "Medium", "Large", "Back");
					stage = 5;
				}
			} else if (componentId == OPTION_2) {
				if (player.getSkills().getLevel(24) < 95) {
					player.getPackets().sendGameMessage("You need a dungeoneering level of at least 95 in order to start a Warped Floor.");
					end();
					return;
				} else {
					sendOptionsDialogue("Select your floor size", "Small", "Medium", "Large", "Back");
					stage = 6;
				}
			} else if (componentId == OPTION_3) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		} else if (stage == 5) {
			if (componentId == OPTION_1) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.SMALL_DUNGEON, 47, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_2) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.MEDIUM_DUNGEON, 47, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_3) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.LARGE_DUNGEON, 47, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_4) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		} else if (stage == 6) {
			if (componentId == OPTION_1) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.SMALL_DUNGEON, 60, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_2) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.MEDIUM_DUNGEON, 60, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_3) {
				if (player.getFamiliar() == null) {
					new DungeonPartyManager(player, new Player[] { player }, DungeonConstants.LARGE_DUNGEON, 60, 6);
					end();
				} else {
					player.getPackets().sendGameMessage("In order to dung, you may not have a familiar.");
					end();
				}
			} else if (componentId == OPTION_4) {
				sendOptionsDialogue("Select your type of floor", "Frozen floor", "Abandoned Floor", "Furnished Floor", "Abandoned2 Floor", "Next page.");
				stage = -1;
			}
		}
	}

	@Override
	public void finish() {
		/*	FriendChatsManager fc = player.getCurrentFriendChat();
		CopyOnWriteArrayList<Player> players = fc.getPlayers();
		for (Player p : players) {
		if (p.getRegionId() != player.getRegionId() || p.isInDungeon() == true) {
			player.getPackets().sendGameMessage("The players you want to dung with has to be in the area of the dungeoneering lobby.");
			return;
	} else {
		new DungeonPartyManager(player, player.getCurrentFriendChat().getPlayers().toArray(new Player[player.getCurrentFriendChat().getPlayers().size()]), DungeonConstants.LARGE_DUNGEON);
		end();
			
			}
		}*/
		

	}

}
